//
//  AppDelegate.swift
//  GASimpleStructDemo
//
//  Created by Gamin on 2020/2/25.
//  Copyright © 2020 gamin.com. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, QQApiInterfaceDelegate {
    func isOnlineResponse(_ response: [AnyHashable : Any]!) {
        
    }

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        TencentOAuth(appId: "101427137",
                     enableUniveralLink: true,
                     universalLink: "ios.vlightv.com",
                     delegate: nil)

//        let testArr = ["abcabcbb", "bbbbb", "pwwkew", ""]
//
//        for testStr in testArr {
//            var lastStr = ""
//            var indexTest = 0
//            var indexFirst = 0
//
//            for string in testStr {
//                if lastStr.contains(string) {
//                    let arr = testStr.split(separator: string)
//                    if arr.count == 0 {
//                        indexTest = 1
//                        break
//                    }
//                    if indexFirst <= String(arr[0]).count + 1 {
//                        indexFirst = String(arr[0]).count + 1
//                    }
//
//                    for string in testStr {
//                        if lastStr.contains(string) {
//                            let arr = testStr.split(separator: string)
//                            if arr.count == 0 {
//                                break
//                            }
//                            if indexFirst <= String(arr[0]).count + 1 {
//                                indexFirst = String(arr[0]).count + 1
//                            }
//                        }
//                        lastStr.append(string)
//                    }
//
//
//
//
//                }
        ////                else {
        ////                    indexTest += 1
        ////                }
//
//                lastStr.append(string)
//            }
//
//            print(indexTest > indexFirst ? indexTest : indexFirst)
//        }
//        return true

        window = UIWindow(frame: UIScreen.main.bounds)
        window?.backgroundColor = UIColor.white

        let responseDict: [String: Any] = [String: Any]()
        print(responseDict)

        let pattern = #">第 1 页，共 ([1-9]\d+) 页</span>"#
        let pattern2 = ">第 1 页，共 ([1-9]d+) 页</span>"

        print("\(pattern)-------\(pattern2)")

//        let fullName = "First Last"
//        let fullNameArr = fullName.split{$0 == " "}.map(String.init)

//        fullNameArr[0] // First
//        fullNameArr[1] // Last

        #if DEVELOPMENT
            print("开发")
        #else
            print("正式")
        #endif

        #if DEBUG
        #else
        #endif

//        是否登录了
        let useDfault = UserDefaults.standard
        if useDfault.object(forKey: "login") != nil {
            window?.rootViewController = TabBarViewController()

        } else {
            window?.rootViewController = LogintViewController()
        }

        window?.makeKeyAndVisible()

        return true
    }

    func openQQUrl(url: URL) {
        QQApiInterface.handleOpenUniversallink(url, delegate: self as QQApiInterfaceDelegate)
    }

    func onReq(_ req: QQBaseReq) {
//        CustomHUD.dismiss()
    }

    // MARK: 收到qq的响应

    func onResp(_ resp: QQBaseResp) {
        if resp.type == 2 {
        }
    }
}
